using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace CXDB
{
    /// <summary>
    /// Controller class for CX_Staff_HR
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class CxStaffHrController
    {
        // Preload our schema..
        CxStaffHr thisSchemaLoad = new CxStaffHr();
        private string userName = String.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}
					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}
				}
				return userName;
            }
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public CxStaffHrCollection FetchAll()
        {
            CxStaffHrCollection coll = new CxStaffHrCollection();
            Query qry = new Query(CxStaffHr.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxStaffHrCollection FetchByID(object Id)
        {
            CxStaffHrCollection coll = new CxStaffHrCollection().Where("ID", Id).Load();
            return coll;
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxStaffHrCollection FetchByQuery(Query qry)
        {
            CxStaffHrCollection coll = new CxStaffHrCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object Id)
        {
            return (CxStaffHr.Delete(Id) == 1);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object Id)
        {
            return (CxStaffHr.Destroy(Id) == 1);
        }
        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(int? UserID,int? DeptID,DateTime? TalkTime,string TalkContent,DateTime? PunishPartyTime,string PunishPartyType,string PunishPartyReason,DateTime? PunishPenalTime,string PunishPenalType,string PunishPenalReason,string PartyProblem,string OtherProblem,int? EnteringUserID,int? ADeptMasterID,string ADeptMasterRemark,int? ADeptMasterStatus,DateTime? ADeptMasterEnteringTime,int? DeptMasterId,string DeptMasterRemark,int? DeptMasterStatus,DateTime? DeptMasterEnteringTime,int? BossUserID,string BossRemark,int? BossStatus,DateTime? BossTime,DateTime? InTime,int? Status,Guid? Guid)
	    {
		    CxStaffHr item = new CxStaffHr();
		    
            item.UserID = UserID;
            
            item.DeptID = DeptID;
            
            item.TalkTime = TalkTime;
            
            item.TalkContent = TalkContent;
            
            item.PunishPartyTime = PunishPartyTime;
            
            item.PunishPartyType = PunishPartyType;
            
            item.PunishPartyReason = PunishPartyReason;
            
            item.PunishPenalTime = PunishPenalTime;
            
            item.PunishPenalType = PunishPenalType;
            
            item.PunishPenalReason = PunishPenalReason;
            
            item.PartyProblem = PartyProblem;
            
            item.OtherProblem = OtherProblem;
            
            item.EnteringUserID = EnteringUserID;
            
            item.ADeptMasterID = ADeptMasterID;
            
            item.ADeptMasterRemark = ADeptMasterRemark;
            
            item.ADeptMasterStatus = ADeptMasterStatus;
            
            item.ADeptMasterEnteringTime = ADeptMasterEnteringTime;
            
            item.DeptMasterId = DeptMasterId;
            
            item.DeptMasterRemark = DeptMasterRemark;
            
            item.DeptMasterStatus = DeptMasterStatus;
            
            item.DeptMasterEnteringTime = DeptMasterEnteringTime;
            
            item.BossUserID = BossUserID;
            
            item.BossRemark = BossRemark;
            
            item.BossStatus = BossStatus;
            
            item.BossTime = BossTime;
            
            item.InTime = InTime;
            
            item.Status = Status;
            
            item.Guid = Guid;
            
	    
		    item.Save(UserName);
	    }
    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int Id,int? UserID,int? DeptID,DateTime? TalkTime,string TalkContent,DateTime? PunishPartyTime,string PunishPartyType,string PunishPartyReason,DateTime? PunishPenalTime,string PunishPenalType,string PunishPenalReason,string PartyProblem,string OtherProblem,int? EnteringUserID,int? ADeptMasterID,string ADeptMasterRemark,int? ADeptMasterStatus,DateTime? ADeptMasterEnteringTime,int? DeptMasterId,string DeptMasterRemark,int? DeptMasterStatus,DateTime? DeptMasterEnteringTime,int? BossUserID,string BossRemark,int? BossStatus,DateTime? BossTime,DateTime? InTime,int? Status,Guid? Guid)
	    {
		    CxStaffHr item = new CxStaffHr();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.Id = Id;
				
			item.UserID = UserID;
				
			item.DeptID = DeptID;
				
			item.TalkTime = TalkTime;
				
			item.TalkContent = TalkContent;
				
			item.PunishPartyTime = PunishPartyTime;
				
			item.PunishPartyType = PunishPartyType;
				
			item.PunishPartyReason = PunishPartyReason;
				
			item.PunishPenalTime = PunishPenalTime;
				
			item.PunishPenalType = PunishPenalType;
				
			item.PunishPenalReason = PunishPenalReason;
				
			item.PartyProblem = PartyProblem;
				
			item.OtherProblem = OtherProblem;
				
			item.EnteringUserID = EnteringUserID;
				
			item.ADeptMasterID = ADeptMasterID;
				
			item.ADeptMasterRemark = ADeptMasterRemark;
				
			item.ADeptMasterStatus = ADeptMasterStatus;
				
			item.ADeptMasterEnteringTime = ADeptMasterEnteringTime;
				
			item.DeptMasterId = DeptMasterId;
				
			item.DeptMasterRemark = DeptMasterRemark;
				
			item.DeptMasterStatus = DeptMasterStatus;
				
			item.DeptMasterEnteringTime = DeptMasterEnteringTime;
				
			item.BossUserID = BossUserID;
				
			item.BossRemark = BossRemark;
				
			item.BossStatus = BossStatus;
				
			item.BossTime = BossTime;
				
			item.InTime = InTime;
				
			item.Status = Status;
				
			item.Guid = Guid;
				
	        item.Save(UserName);
	    }
    }
}
